class ProxyObserver {

  constructor() {
    this.count = 0;
  }

  _others2Object(notObj) {
    let obj;
    if (notObj) {
      typeof notObj === 'number' && (obj = new Number(notObj));
      typeof notObj === 'string' && (obj = new String(notObj));
    } else {
      throw new Error(`ReferenceError: Can't find '${notObj}'.`);
    }
    return obj;
  }

  createProxy(proxyTarget) {

    typeof proxyTarget !== 'object' && (proxyTarget = this._others2Object(proxyTarget));

    console.log(proxyTarget);

    return new Proxy(proxyTarget, {
      set: () => {
        console.log(`set => `);
      },

      get: () => {
        this.count++;
        console.log(`get => `, this.count);
      }
    });
  }
}

// ------ TEST BEGIN ------ //

function test() {
  let icy = new ProxyObserver();
  
  let a =icy.createProxy(7);
  let b = typeof a;
  console.log(a, icy.count);
  console.log(b, icy.count);

}

test();

// ------ TEST END ------//